package com.example.demo.app;

import com.example.demo.domain.app.param.ProductParam;
import com.example.demo.domain.app.vo.ProductDetailVO;
import com.example.demo.domain.app.vo.ProductVO;
import com.example.demo.domain.app.vo.ReputationVO;
import com.example.demo.domain.base.BaseResult;
import com.example.demo.domain.base.PageResult;
import com.example.demo.service.ProductManagementService;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * 商品
 *
 * @author haochen78
 * @date 2025/11/6 21:19
 **/
@RestController
@RequestMapping("/app/shop/goods")
public class AppProductController {

    @Autowired
    private ProductManagementService productManagementService;

    /**
     * 商品列表
     *
     * @param param 查下参数
     * @return 列表
     */
    @PostMapping("/list/v2")
    public BaseResult<PageResult<ProductVO>> productList(@RequestBody ProductParam param) {
        if (ObjectUtils.anyNotNull(param.getMiaosha(), param.getKanjia(), param.getPingtuan())) {
            return BaseResult.success(new PageResult<>(new PageInfo<>(Collections.emptyList())));
        }
        return BaseResult.success(productManagementService.appList(param));
    }

    @GetMapping("/goodsAddition")
    public BaseResult<PageResult<ProductVO>> goodsAddition() {
        return BaseResult.success();
    }

    @GetMapping("/fav/check")
    public BaseResult<PageResult<ProductVO>> check() {
        return BaseResult.success(new PageResult<>(new PageInfo<>(Collections.emptyList())));
    }

    @GetMapping("/kanjia/set/v2")
    public BaseResult<List<ProductVO>> bargainProductList() {
        return BaseResult.failure();
    }

    /**
     * 商品详情
     *
     * @param id 商品id，
     * @return 评价
     */
    @GetMapping("/detail")
    public BaseResult<ProductDetailVO> detail(@RequestParam Long id) {
        ProductDetailVO detail = productManagementService.detail(id);
        return BaseResult.success(detail);
    }

    /**
     * 商品评价
     *
     * @param param 商品id，
     */
    @PostMapping("/reputation/v2")
    public BaseResult<PageResult<ReputationVO>> reputation() {
        return BaseResult.success(new PageResult<>(new PageInfo<>(Collections.emptyList())));
    }
}
